package com.zx.listener;

import com.alibaba.fastjson.JSON;
import com.zx.entity.Order;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * 监听创建订单成功
 * @author jack.wu
 * @version 1.0
 * @date 2020-03-10
 */
@Slf4j
@Service
@RocketMQMessageListener(
        consumerGroup = "shop-user", // 消费组名
        topic = "order-topic", //消费的topic
        consumeMode = ConsumeMode.ORDERLY, //消费模式 ：无序和有序
        messageModel = MessageModel.BROADCASTING //消息模式 ：集群和广播
       )
public class OrderListener implements RocketMQListener<Order> {

    @Override
    public void onMessage(Order order) {
        log.info("收到一个订单信息{}，接下来发短信息。。。", JSON.toJSONString(order));
    }
}
